<template>
  <view class="content">
    <titleBox :item="item" class="titleCare"></titleBox>
	<view class="setdata" v-for="item in journalList" :key="item.id">
		<text class="setMonth">
			{{item.month}}
		</text>
		<view class="content-journal" v-for="item in item.data" :key="item.id"	 >
			<journalCard :item="item"></journalCard>
		</view>
	
	</view>
	<view @click="addMoreJournal" class="addMore">{{more}}</view>
	<view class="add" @click="checkEditor()">
		<uni-icons type="plusempty" size="30" color="white"></uni-icons>
	</view>
	<view class="toTreeHold" @click="checkTreeHold()">
		<image src="https://mp-6f81e20c-45ed-420c-8b9c-c84e21bce18b.cdn.bspapp.com/icon/tree.png" class="treeHodldIcon"></image>
	</view>	
  </view>
</template>

<script>

import {getJournalByAuthorId} from '@/api/journal.js';

  export default {
    data() {
      return {
        item:{
			pageName:'index'
		},
		more:"加载更多...",
		journalList:[],
		"id": "",
		"currentPage":0
      };
    },
    onLoad() {
		this.id = uni.getStorageSync("id")
		this.journalList=[]
		this.getJournalList()
		
	},
	onReachBottom() {
		this.addMoreJournal()
	},
    methods: {
		checkEditor(){
			uni.navigateTo({
				url:"/pages/editor/editor"
			})
		},
		checkTreeHold(){
			uni.navigateTo({
				url:"/pages/treeHold/treeHold"
			})
		},
		// 分页
		addMoreJournal(){
			this.currentPage += 1
			this.getJournalList()
		},
		//日记列表
		getJournalList(){
			
			getJournalByAuthorId({
				"id": this.id,
				"currentPage":this.currentPage,
				"token":uni.getStorageSync("authorization")
			}).then(res=>{

				if(res.data.data!=null){
					this.journalList.push(res.data.data)
				}else{
					this.more = "没有更多数据了..."
				}
			})
			

		}
		
	},
  };
</script>

<style lang="scss">
page{
	padding-top: 10vh;
	width: 100%;
	height: 100%;
	background: url('@/static/bg.png')  no-repeat center center fixed ;
	background-size: cover;
	box-sizing: border-box;
	
}
.content {
	.titleCare{
		position: fixed;
		width: 100%;
		top: 0;
	}
	
	.setdata{
		.setMonth{
			font-size: 50rpx;
			color: white;
			padding: 100rpx 0;
		}
		
	}
	.add{
		width: 100rpx;
		height: 100rpx;
		background-color: $font-blue;
		position: fixed;
		bottom: 80rpx;
		right: 10%;
		border-radius: 100rpx 100rpx;
		line-height:100rpx;
		text-align: center;
		
	}
	.toTreeHold{
		display: flex;  
		justify-content: center;  
		align-items: center;  
		height: 100rpx;  
		width: 100rpx;  
		background-color: seagreen;  
		position: fixed;  
		bottom: 80rpx;  
		right: 30%;  
		border-radius: 100rpx 100rpx;  
		line-height:100rpx;  
		text-align: center; 
		.treeHodldIcon{
			width: 80%;
			height: 80%;
			padding-left: 6rpx;
		}
	}
	.addMore{
		width: 100%;
		text-align: center;
		color: white;
		font-size: 2.2vh;
		padding-top: 60rpx;
		
	}
}
</style>